package com.erms.lab.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.erms.common.annotation.Log;
import com.erms.common.enums.BusinessType;
import com.erms.lab.domain.SysAttendConference;
import com.erms.lab.service.ISysAttendConferenceService;
import com.erms.common.core.controller.BaseController;
import com.erms.common.core.domain.AjaxResult;
import com.erms.common.utils.poi.ExcelUtil;
import com.erms.common.core.page.TableDataInfo;

/**
 * 参加大型会议情况Controller
 * 
 * @author guo
 * @date 2020-03-22
 */
@Controller
@RequestMapping("/lab/conference")
public class SysAttendConferenceController extends BaseController
{
    private String prefix = "lab/conference";

    @Autowired
    private ISysAttendConferenceService sysAttendConferenceService;

    @RequiresPermissions("lab:conference:view")
    @GetMapping()
    public String conference()
    {
        return prefix + "/conference";
    }

    /**
     * 查询参加大型会议情况列表
     */
    @RequiresPermissions("lab:conference:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysAttendConference sysAttendConference)
    {
        startPage();
        List<SysAttendConference> list = sysAttendConferenceService.selectSysAttendConferenceList(sysAttendConference);
        return getDataTable(list);
    }

    /**
     * 导出参加大型会议情况列表
     */
    @RequiresPermissions("lab:conference:export")
    @Log(title = "参加大型会议情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysAttendConference sysAttendConference)
    {
        List<SysAttendConference> list = sysAttendConferenceService.selectSysAttendConferenceList(sysAttendConference);
        ExcelUtil<SysAttendConference> util = new ExcelUtil<SysAttendConference>(SysAttendConference.class);
        return util.exportExcel(list, "conference");
    }

    /**
     * 新增参加大型会议情况
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存参加大型会议情况
     */
    @RequiresPermissions("lab:conference:add")
    @Log(title = "参加大型会议情况", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysAttendConference sysAttendConference)
    {
        return toAjax(sysAttendConferenceService.insertSysAttendConference(sysAttendConference));
    }

    /**
     * 修改参加大型会议情况
     */
    @GetMapping("/edit/{attId}")
    public String edit(@PathVariable("attId") Long attId, ModelMap mmap)
    {
        SysAttendConference sysAttendConference = sysAttendConferenceService.selectSysAttendConferenceById(attId);
        mmap.put("sysAttendConference", sysAttendConference);
        return prefix + "/edit";
    }

    /**
     * 修改保存参加大型会议情况
     */
    @RequiresPermissions("lab:conference:edit")
    @Log(title = "参加大型会议情况", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysAttendConference sysAttendConference)
    {
        return toAjax(sysAttendConferenceService.updateSysAttendConference(sysAttendConference));
    }

    /**
     * 删除参加大型会议情况
     */
    @RequiresPermissions("lab:conference:remove")
    @Log(title = "参加大型会议情况", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysAttendConferenceService.deleteSysAttendConferenceByIds(ids));
    }
}
